import React, { forwardRef, useState, useImperativeHandle } from 'react';

export type SonRef = {
    setList: (newList: any[]) => void;
};

const Index = forwardRef<SonRef, {}>((props, ref) => {
    const [list, setList] = useState(['渲染元素.1', '渲染元素.2']);

    useImperativeHandle(ref, () => ({
        setList,
    }));

    return (
        <>
            <h3
                onClick={() => {
                    console.log('Current path:', location.pathname);
                }}
            >
                son:{' '}
                <span style={{ fontSize: 14, color: '#000' }}>{list.map((str) => str.concat('1')).join('、')}</span>
            </h3>
        </>
    );
});

export default Index;
